package com.rs2hd.packethandler;

import com.rs2hd.model.Player;
import com.rs2hd.net.Packet;
import org.apache.mina.common.IoSession;
import com.rs2hd.model.World;

public class ObjectPacketHandler implements PacketHandler {

	@Override
	public void handlePacket(Player player, IoSession session, Packet packet) {
		switch (packet.getId()) {
		case 45:
			option1(player, session, packet);
			break;
		case 190:
			option2(player, session, packet);
			break;
		}
	}
	private void option1(final Player player, IoSession session, Packet packet) {
		final int x = packet.readShort() & 0xFFFF;
		@SuppressWarnings("unused") final int junk = packet.readByte();
		final int id = packet.readLEShort() & 0xFFff;
		final int y = packet.readLEShort() & 0xFFFF;
		System.out.println("Xcoord: " + x + " Ycoord: " + y + " ObjectId: " + id);
		player.clickX = x;
		player.clickY = y;
		switch (id) {
		case 36972:  player.getSkills().RestorePray(99); 
		player.getActionSender().sendMessage("You restore your pray");
		break;
                case 36687:
                player.animate(827, 0);
                player.tele(3210 ,9616 , 0);
                break;
                case 29355:
                player.animate(828, 0);
                player.tele(3209 ,3215 , 0);
                break;
                case 4387:
                player.tele(2420 ,3106 , 0);
		player.getActionSender().sendMessage("Keep Items On Death. SAFE ZONE.");
                break;
                case 4408:
                player.tele(1663 ,5696 , 0);
		player.getActionSender().sendMessage("MULTI ZONE, Keep Items On Death. SAFE ZONE.");
                break;
                case 4388:
                player.tele(3296 ,3649 , 0);
		player.getActionSender().sendMessage("Items DROP On Death. DANGEROUS ZONE.");
                break;
		case 11402:
							World.getInstance().getShopManager().openShop(player, 1);
		break;
		case 4483:
		player.getBank().openBank();
		break;
		case 1276:
		case 1277:
		case 1278:
		case 1279:
		case 1280:
		case 1282:
		case 1283:
		case 1284:
		case 1285:
		case 1286:
		case 1289:
		case 1290: 
		case 1291:
		case 1315:
		case 1316:
		case 1318:
		case 1319:
		case 1330:		
		case 1331:
		case 1332: 
		case 1365:
		case 1383:  
		case 1384:
		case 2409: 
		case 3033:
		case 3034:
		case 3035: 
		case 3036:	
		case 3881:
		case 3882:		
		case 3883:  
		case 5902:
		case 5903:  
		case 5904: /* Normal */
		case 1308:
		case 5551:
		case 5552:
		case 5553:/* Willow */
		case 1281:
		case 3037:/* Oak */
		case 1292: 
		case 1306:/* Magic */
		case 1307:
		case 4674:/* Maple */
		case 9034:/* Mahogany */
		case 9036:/* Teak */
		case 2023: /* Achey */
		case 1309: /* Yews */
			player.getWoodcutting().startCutting(id);
			break; 
		}
	}

	private void option2(final Player player, IoSession session, Packet packet) {
		@SuppressWarnings("unused") final int junk = packet.readByte() & 0xFFFF;
		final int y = packet.readShortA() & 0xFFFF;
		final int id = packet.readShort() & 0xFFFF;
		final int x = packet.readShort() & 0xFFFF;
		System.out.println("Xcoord: " + x + " Ycoord: " + y + " ObjectId: " + id);
		switch (id) {

		}
	}

}
